-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove condition/c_if, duration, and unit from instructions #13506
base: main
Are you sure you want to change the base?
Conversation
This commit removes the per instruction attributes for condition, duration, and unit. These attributes were deprecated in 1.3.0. Besides the label these attributes were the only mutable state for singleton instructions and removing them simplifies what needs to be tracked for instructions in both Python and rust. The associated methods and classes that were previously dependent on these attributes are also removed as they no longer serve a purpose. The removal of condition in particular removes a lot of logic from Qiskit especially from the transpiler because it was a something that needed to be checked outside of the normal data model for every operation. This PR simplifies the representation of this extra mutable state in Rust by removing the `ExtraInstructionAttributes` struct and replacing it with a `Option<Box<String>>`. The `Option<Box<String>>` is used instead of the simpler `Option<String>` because this this reduces the size of the label field from 24 bytes for `Option<String>` to 8 bytes for `Option<Box<String>>` with an extra layer of pointer indirection and a second heap allocation. This will have runtime overhead when labels are set, but because the vast majority of operations don't set labels the tradeoff for optimizing for the None case makes more sense. Another option would have been to use `Box<str>` here which is the equivalent of `Box<[u8]>` (where `String` is the equivalent to `Vec<u8>`) and from a runtime memory tradeoff would be a better choice for this application if labels were commonly used as labels aren't growable. But that requires 16 bytes instead of 8 and we'd be wasting an additional 8 bytes for each instruction in the circuit which isn't worth the cost.
Is there a replacement method for getting circuit timing if |
Aside from the failing tests in |
…#2301) * Adjust QuantumError.to_dict() to handle lack of Instruction.condition In Qiskit 2.0 the Instruction.condition attribute will be removed following it's deprecation in 1.3.0. This attribute has been superseded by the IfElseOp which covers the use case but offers more functionality. The removal is pending in Qiskit/qiskit#13506 and the use of qiskit-aer in Qiskit's tests is blocking progress on that PR. This commit makes the usage of .condition optional to maintain compatibility with Qiskit<2.0 but also work in >=2.0 with the attribute removed. * Handle condition for AerJump as a custom attribute With the removal of .condition from the base instruction data model the .c_if() method was also removed. To handle the conditional jump that AerJump was used for a custom attribute .condition is added to the instruction. This enables retaining the functionality, but doesn't rely on the base data model to provide the attribute or method.
In Qiskit#13506 the QPY backwards compatibility tests are failing because the image is running out of disk space and github actions is killing the runner. The qpy files themselves should be fairly small and will be dwarfed by the virtual environments created to install old versions of qiskit to generate old QPY payloads. We use GNU parallel to speed up the testing, however by doing this we end up having multiple venvs at once which increases the disk space usage. This commit attempts to reduce the pressure on the disk space usage by decreasing the parallelism from N cpus (which is currently 4 for linux runners according to [1]) to 2. This will increase the runtime for this job but if we have insufficient disk space on the image to generate new qpy files there isn't really a choice. [1] https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
In #13506 the QPY backwards compatibility tests are failing because the image is running out of disk space and github actions is killing the runner. The qpy files themselves should be fairly small and will be dwarfed by the virtual environments created to install old versions of qiskit to generate old QPY payloads. We use GNU parallel to speed up the testing, however by doing this we end up having multiple venvs at once which increases the disk space usage. This commit attempts to reduce the pressure on the disk space usage by decreasing the parallelism from N cpus (which is currently 4 for linux runners according to [1]) to 2. This will increase the runtime for this job but if we have insufficient disk space on the image to generate new qpy files there isn't really a choice. [1] https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
In #13506 the QPY backwards compatibility tests are failing because the image is running out of disk space and github actions is killing the runner. The qpy files themselves should be fairly small and will be dwarfed by the virtual environments created to install old versions of qiskit to generate old QPY payloads. We use GNU parallel to speed up the testing, however by doing this we end up having multiple venvs at once which increases the disk space usage. This commit attempts to reduce the pressure on the disk space usage by decreasing the parallelism from N cpus (which is currently 4 for linux runners according to [1]) to 2. This will increase the runtime for this job but if we have insufficient disk space on the image to generate new qpy files there isn't really a choice. [1] https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories (cherry picked from commit b718f06)
In #13506 the QPY backwards compatibility tests are failing because the image is running out of disk space and github actions is killing the runner. The qpy files themselves should be fairly small and will be dwarfed by the virtual environments created to install old versions of qiskit to generate old QPY payloads. We use GNU parallel to speed up the testing, however by doing this we end up having multiple venvs at once which increases the disk space usage. This commit attempts to reduce the pressure on the disk space usage by decreasing the parallelism from N cpus (which is currently 4 for linux runners according to [1]) to 2. This will increase the runtime for this job but if we have insufficient disk space on the image to generate new qpy files there isn't really a choice. [1] https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories (cherry picked from commit b718f06) Co-authored-by: Matthew Treinish <[email protected]>
I ran a quick asv run to see if there was a performance impact to this change, and it does speed things up by about 10%:
|
One or more of the following people are relevant to this code:
|
The tests fail because of a circuit equality issue, form experience it's differing bit lists in the if state blocks.
Summary
This commit removes the per instruction attributes for condition, duration, and unit. These attributes were deprecated in 1.3.0. Besides the label these attributes were the only mutable state for singleton instructions and removing them simplifies what needs to be tracked for instructions in both Python and rust. The associated methods and classes that were previously dependent on these attributes are also removed as they no longer serve a purpose. The removal of condition in particular removes a lot of logic from Qiskit especially from the transpiler because it was a something that needed to be checked outside of the normal data model for every operation.
This PR simplifies the representation of this extra mutable state in Rust by removing the
ExtraInstructionAttributes
struct and replacing it with aOption<Box<String>>
. TheOption<Box<String>>
is used instead of the simplerOption<String>
because this this reduces the size of the label field from 24 bytes forOption<String>
to 8 bytes forOption<Box<String>>
with an extra layer of pointer indirection and a second heap allocation. This will have runtime overhead when labels are set, but because the vast majority of operations don't set labels the tradeoff for optimizing for the None case makes more sense. Another option would have been to useBox<str>
here which is the equivalent ofBox<[u8]>
(whereString
is the equivalent toVec<u8>
) and from a runtime memory tradeoff would be a better choice for this application if labels were commonly used as labels aren't growable. But that requires 16 bytes instead of 8 and we'd be wasting an additional 8 bytes for each instruction in the circuit which isn't worth the cost.Details and comments
TODO:
c_if
usage in tests (there's >200 instances of it still)